home *** CD-ROM | disk | FTP | other *** search
/ Gurewich OLE Controls for Visual Basic 4 / Gurewich OLE Controls for Visual Basic 4.iso / ocxprog / programs / ch15 / wingtest.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-24  |  7.0 KB  |  218 lines

  1. VERSION 4.00
  2. Begin VB.Form frmWinGTest 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "The WinG Test Program"
  5.    ClientHeight    =   4230
  6.    ClientLeft      =   930
  7.    ClientTop       =   1800
  8.    ClientWidth     =   7005
  9.    Height          =   4920
  10.    Icon            =   "WINGTEST.frx":0000
  11.    Left            =   870
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   282
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   467
  17.    Top             =   1170
  18.    Width           =   7125
  19.    Begin VB.Label lblInstructions 
  20.       Caption         =   $"WINGTEST.frx":030A
  21.       Enabled         =   0   'False
  22.       BeginProperty Font 
  23.          name            =   "MS Sans Serif"
  24.          charset         =   0
  25.          weight          =   400
  26.          size            =   12
  27.          underline       =   0   'False
  28.          italic          =   0   'False
  29.          strikethrough   =   0   'False
  30.       EndProperty
  31.       ForeColor       =   &H00000000&
  32.       Height          =   975
  33.       Left            =   840
  34.       TabIndex        =   0
  35.       Top             =   600
  36.       Width           =   5295
  37.    End
  38.    Begin VB.Shape shpRedRectangle 
  39.       BackColor       =   &H000000FF&
  40.       BackStyle       =   1  'Opaque
  41.       Height          =   495
  42.       Left            =   2880
  43.       Top             =   3360
  44.       Visible         =   0   'False
  45.       Width           =   615
  46.    End
  47.    Begin VB.Shape shpWhiteRectangle 
  48.       BackColor       =   &H00FFFFFF&
  49.       BackStyle       =   1  'Opaque
  50.       BorderColor     =   &H00000000&
  51.       Height          =   735
  52.       Left            =   2520
  53.       Top             =   2520
  54.       Visible         =   0   'False
  55.       Width           =   1335
  56.    End
  57.    Begin TegwingLibCtl.Tegwing Tegwing1 
  58.       Left            =   2880
  59.       Top             =   1920
  60.       _version        =   65536
  61.       _extentx        =   1032
  62.       _extenty        =   953
  63.       _stockprops     =   0
  64.    End
  65.    Begin VB.Menu mnuFile 
  66.       Caption         =   "&File"
  67.       Begin VB.Menu mnuExit 
  68.          Caption         =   "E&xit"
  69.       End
  70.    End
  71.    Begin VB.Menu mnuOptions 
  72.       Caption         =   "&Options"
  73.       Begin VB.Menu mnuDrawWithWinG 
  74.          Caption         =   "Draw With &WinG"
  75.       End
  76.       Begin VB.Menu mnuDrawWithoutWinG 
  77.          Caption         =   "&Draw Without WinG"
  78.       End
  79.    End
  80.    Begin VB.Menu mnuHelp 
  81.       Caption         =   "&Help"
  82.       Begin VB.Menu mnuAbout 
  83.          Caption         =   "&About..."
  84.       End
  85.    End
  86. Attribute VB_Name = "frmWinGTest"
  87. Attribute VB_Creatable = False
  88. Attribute VB_Exposed = False
  89. ' All variables must be declared.
  90. Option Explicit
  91. ' Constants used for drawing.
  92. Const PS_SOLID = 0
  93. Const PS_DASH = 1
  94. Const PS_DOT = 2
  95. Const PS_DASHDOT = 3
  96. Const PS_DASHDOTDOT = 4
  97. Const PS_NULL = 5
  98. Const PS_INSIDEFRAME = 6
  99. Private Sub Form_Load()
  100. ' Set the scale mode to units of Pixels.
  101. Me.ScaleMode = 3
  102. ' Tell the WinG control in which window to draw.
  103. Tegwing1.hWndDisplay = Me.hWnd
  104. ' Open a WinG session
  105. Tegwing1.OpenWinG
  106. ' Place a check mark next to the Draw With WinG
  107. ' menu item.
  108. mnuDrawWithWinG.Checked = True
  109. ' Disable the Instructions label.
  110. lblInstructions.Enabled = False
  111. End Sub
  112. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  113. Dim RectWidth, RectHeight
  114. ' if the Draw With WinG menu item has a check mark,
  115. ' draw with WinG. Otherwise, draw without WinG.
  116. If mnuDrawWithWinG.Checked = True Then
  117.    ' Draw the white rectangle inside WinG
  118.    Tegwing1.SetPen PS_SOLID, 1, RGB(255, 255, 255)
  119.    Tegwing1.SetSolidBrush RGB(255, 255, 255)
  120.    RectWidth = Tegwing1.WinGWidth
  121.    RectHeight = Tegwing1.WinGHeight
  122.    Tegwing1.DrawRectangle 0, 0, RectWidth - 1, RectHeight - 1
  123.    ' Draw the red rectangle inside WinG
  124.    Tegwing1.SetSolidBrush RGB(255, 0, 0)
  125.    Tegwing1.DrawRectangle X, Y, X + 150, Y + 150
  126.          
  127.    ' Slam WinG into the screen.
  128.    Tegwing1.SlamIt
  129.      
  130.    ' Hide the Instructions label.
  131.    lblInstructions.Visible = False
  132.    ' Draw the white rectangle
  133.    shpWhiteRectangle.Top = 0
  134.    shpWhiteRectangle.Height = Me.ScaleHeight
  135.    shpWhiteRectangle.Left = 0
  136.    shpWhiteRectangle.Width = Me.ScaleWidth
  137.    shpWhiteRectangle.Visible = True
  138.    ' Draw the red rectangle
  139.    shpRedRectangle.Top = Y
  140.    shpRedRectangle.Height = 150
  141.    shpRedRectangle.Left = X
  142.    shpRedRectangle.Width = 150
  143.    shpRedRectangle.Visible = True
  144. End If
  145. End Sub
  146. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  147. ' If the mouse button is not pressed, terminate
  148. ' this procedure.
  149. If Button = 0 Then Exit Sub
  150. ' Call the Form_MouseDown() procedure.
  151. Form_MouseDown Button, Shift, X, Y
  152. End Sub
  153. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  154.         
  155. ' Hide the two shape controls.
  156. shpWhiteRectangle.Visible = False
  157. shpRedRectangle.Visible = False
  158. ' Make the Instructions label visible.
  159. lblInstructions.Visible = True
  160. ' Clear the screen.
  161. Me.Cls
  162. End Sub
  163. Private Sub Form_Unload(Cancel As Integer)
  164.    ' Close the WinG session
  165.    Tegwing1.CloseWinG
  166. End Sub
  167. Private Sub mnuAbout_Click()
  168.    Dim Title
  169.    Dim Msg
  170.    Dim CR
  171.    CR = Chr(13) + Chr(10)
  172.    ' The title of the About message box.
  173.    Title = "About the WinG Program"
  174.    ' Prepare the message of the About message box.
  175.    Msg = "This program was written with Visual "
  176.    Msg = Msg + "Basic for Windows, using the "
  177.    Msg = Msg + "TegoSoft WinG OCX control. "
  178.    Msg = Msg + CR + CR
  179.    Msg = Msg + "The TegoSoft WinG OCX control "
  180.    Msg = Msg + "enables you to perform fast graphics "
  181.    Msg = Msg + "operations (such as display BMP files) "
  182.    Msg = Msg + "using WinG technology."
  183.    Msg = Msg + CR + CR
  184.    Msg = Msg + "The TegoSoft WinG OCX control "
  185.    Msg = Msg + "is part of the TegoSoft OCX Control "
  186.    Msg = Msg + "Kit - a collection of various OCX controls. "
  187.    Msg = Msg + CR + CR
  188.    Msg = Msg + "For more information about the "
  189.    Msg = Msg + "TegoSoft OCX Control Kit, contact TegoSoft "
  190.    Msg = Msg + "at:"
  191.    Msg = Msg + CR + CR
  192.    Msg = Msg + "TegoSoft Inc." + CR
  193.    Msg = Msg + "P.O. Box 389" + CR
  194.    Msg = Msg + "Bellmore, NY 11710"
  195.    Msg = Msg + CR + CR
  196.    Msg = Msg + "Phone: (516)783-4824"
  197.    ' Display the About message box.
  198.    MsgBox Msg, vbInformation, Title
  199. End Sub
  200. Private Sub mnuDrawWithoutWinG_Click()
  201. ' Place a check mark next to the Draw Without WinG
  202. ' menu item, and remove the check mark from the
  203. ' Draw With WinG menu item.
  204. mnuDrawWithoutWinG.Checked = True
  205. mnuDrawWithWinG.Checked = False
  206. End Sub
  207. Private Sub mnuDrawWithWinG_Click()
  208. ' Place a check mark next to the Draw With WinG
  209. ' menu item, and remove the check mark from the
  210. ' Draw Without WinG menu item.
  211. mnuDrawWithWinG.Checked = True
  212. mnuDrawWithoutWinG.Checked = False
  213. End Sub
  214. Private Sub mnuExit_Click()
  215. ' Terminate the program.
  216. Unload Me
  217. End Sub
  218.